package cc.vv.btpartyjob.partymanager.delegate

import android.support.v4.view.ViewPager
import android.view.View
import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.btpartyjob.partymanager.R
import cc.vv.btpartyjob.partymanager.adapter.ManagerViewPageAdapter
import cc.vv.mvp.delegate.BaseAppDelegate

/**
 * 党员承诺托管类
 * Created by Chen.qi on 2018/10/24.
 */
class PartyPromiseActivityDelegate : BaseAppDelegate() {


    override fun initWidget() {

    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_party_promise
    }

    /**设置标题title*/
    fun setTopBarTitle(topBarTitle: String, isShow: Boolean = false) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_app_topBar)
        titleBar?.setTitle(topBarTitle)
        if (isShow) {
            titleBar?.rl_ljtb_right_layout?.visibility = View.VISIBLE
        } else {
            titleBar?.rl_ljtb_right_layout?.visibility = View.GONE
        }
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_app_topBar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 设置评价未评价的状态
     */
    fun setEvaluateSelect(isSelectYes: Boolean) {
        val evaluateNo = getView<TextView>(R.id.tv_app_evaluateNo)
        val evaluateYes = getView<TextView>(R.id.tv_app_evaluateYes)
        evaluateNo?.isSelected = isSelectYes
        evaluateYes?.isSelected = !isSelectYes
    }

    /**
     * 设置adatper
     */
    fun setAdapterData(adapter: ManagerViewPageAdapter) {
        getView<ViewPager>(R.id.vp_app_evaluate)?.adapter = adapter
    }

    /**
     * 设置viewpager位置
     */
    fun setViewPagerPos(currentPos: Int) {
        getView<ViewPager>(R.id.vp_app_evaluate)?.currentItem = currentPos

    }

    /**
     * 设置viewPager的监听
     */
    fun bindViewPagerLisener(listener: ViewPager.OnPageChangeListener) {
        getView<ViewPager>(R.id.vp_app_evaluate)?.addOnPageChangeListener(listener)
    }

}